from config import HOST


class ApiApproveTrust:
    # 初始化
    def __init__(self, session):
        # 获取session对象
        self.session = session
        # 认证url
        self.__url_approve = HOST + "/member/realname/approverealname"
        # 查询认证状态url
        self.__url_approve_status = HOST + "/member/member/getapprove"
        # 开户url
        self.__url_trust = HOST + "/trust/trust/register"

    # 1、认证接口 封装
    def api_approve(self):
        # 1、请求数据
        data = {
            "realname": "张三",
            "card_id": "110101201703072050"
        }
        # 2、调用方法 难点：请求要 multipart-form/data -> data + files
        return self.session.post(url=self.__url_approve, data=data, files={"x": "y"})

    # 2、查询认证状态接口 封装
    def api_approve_status(self):
        return self.session.post(url=self.__url_approve_status)

    # 3、开户接口
    def api_trust(self):
        return self.session.post(url=self.__url_trust)
